import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [{
  path: '/login',
  component: () =>
    import('@/views/login/index'),
  hidden: true
}]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})

export const asyncRouterMap = [{
  path: '',
  component: Layout,
  redirect: '/dashboard',
  children: [{
    path: 'dashboard',
    component: () => import('@/views/dashboard/index'),
    name: 'dashboard',
    meta: { title: '统计', icon: 'dashboard', noCache: true }
  }]
},
{
  path: '/All_order',
  component: Layout,
  redirect: '/All_order/all_order',
  name: '所有订单',
  meta: {
    title: '所有订单',
    icon: '订单',
    roles: ['admin', 'Customer']
  },
  children: [{
    path: 'airtickets_order',
    name: 'airtickets_order',
    component: () => import('@/views/all_order/airtickets_order/index'),
    meta: {
      title: '机票订单',
      icon: '机票'
    }
  },
  {
    path: 'completed_order',
    name: 'completed_order',
    component: () => import('@/views/all_order/completed_order/index'),
    meta: {
      title: '已完成的订单',
      icon: '已完成的订单'
    }
  }
  ]
},
{
  path: '/Ticketing',
  component: Layout,
  redirect: '/Ticketing/airtickets_info',
  name: '票务管理',
  meta: {
    title: '票务管理',
    icon: '票务管理',
    roles: ['admin']
  },
  children: [{
    path: 'airtickets_info',
    name: '航班管理',
    component: () => import('@/views/all_info/airtickets_info/index'),
    meta: {
      title: '航班管理',
      icon: '航班'
    }
  }, {
    path: 'hotel_info',
    name: '酒店管理',
    component: () => import('@/views/all_info/hotel_info/index'),
    meta: {
      title: '酒店管理',
      icon: '酒店'
    }
  }
  ]
},
{
  path: '/System_management',
  component: Layout,
  redirect: '/System_management/user_rights',
  name: '系统管理',
  meta: {
    title: '系统管理',
    icon: '系统管理',
    roles: ['admin']
  },
  children: [{
    path: 'user_rights',
    name: '用户管理',
    component: () =>
      import('@/views/system_management/user_rights/index'),
    meta: {
      title: '用户管理',
      icon: '用户管理'
    }
  }]
},
{ path: '/404', component: () => import('@/views/errorPage/404.vue') }
]
